{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data Structure: Boundary Conditions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We use `bdFlag(1:NT,1:3)` to record the type of three edges of each\n",
    "triangle. Similarly in 3-D, we use `bdFlag(1:NT,1:4)` to record the type\n",
    "of four faces of each tetrahedron. The value is the type of boundary\n",
    "condition.\n",
    "\n",
    "- 0: non-boundary, i.e., an interior edge or face.\n",
    "- 1: first type, i.e., a Dirichlet boundary edge or face. \n",
    "- 2: second type, i.e., a Neumann boundary edge or face. \n",
    "- 3: third type, i.e., a Robin boundary edge or face.\n",
    "\n",
    "For a boundary edge/face, the type is 0 means homogenous Neumann boundary condition (zero\n",
    "flux).\n",
    "\n",
    "The function `setboundary` is to set up the bdFlag matrix for a 2-D\n",
    "triangulation and `setboundary3` for a 3-D triangulation. Examples\n",
    "\n",
    "- `bdFlag = setboundary(node,elem,'Dirichlet','abs(x) + abs(y) == 1','Neumann','y==0');`\n",
    "\n",
    "- `bdFlag = setboundary3(node,elem,'Dirichlet','(z==1) | (z==-1)');`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Local labeling of edges and faces"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We label three edges of a triangle such that `bdFlag(t,i)` is the edge\n",
    "opposite to the i-th vertex. Similarly `bdFlag(t,i)` is the face opposite\n",
    "to the i-th vertex."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4gkHFDg1XZw5lQAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwNy1TZXAtMjAxOCAx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JVF\nwMQaEpA0cznwr9c/ICKrvHdN7EnajJaNtXfb62QdkFYECZiISTaJGgGjESRggibcJGoEjIkgARM3\nvEmLtLJxv9S8M3I8GGpo0J+hRsBoXGUHTJau61VVVYZh5HsKirWyRdr1wz+AtTNyvM1440TkeMOH\nF0HY5UMZgAwjSEAKmN9V39TUpOu6+eExZpw6Ix1tRouIaJrm9/srKys5MAJiIUhAipkfstnU1CQf\nfqQmnxwDJIIgAQCUwBtjAQBKIEgAACUQJACAEggSAEAJBAkAoASCBABQAkECACiBIAEAlECQAABK\nIEgAACUQJACAEggSAEAJBAkAoASCBABQAkECACiBIAEAlECQAABKIEgAACUQJACAEggSAEAJBAkA\noASCBABQAkECACiBIAEAlECQAABKIEgAACUQJACAEggSAEAJBAkAoASCBABQAkECACiBIAEAlECQ\nAABKIEgAACX8P8vSWZIifnThAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [1,0; 1,1; 0,0];\n",
    "elem = [1 2 3];\n",
    "locEdge = [2 3; 3 1; 1 2];\n",
    "showmesh(node,elem);\n",
    "findnode(node);\n",
    "findedge(node,locEdge,'all','vec');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The ordering of edges is specified by `locEdge`. If we use `locEdge = [2 3; 1 3; 1 2]`, we get asecond orientation of edges."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Extract Boundary Edges and Faces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: Crack Domain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "elem =\n",
      "\n",
      "     5     1     2\n",
      "     5     2     3\n",
      "     5     3     4\n",
      "     5     4     6\n",
      "\n",
      "\n",
      "bdFlag =\n",
      "\n",
      "    1    0    1\n",
      "    1    0    0\n",
      "    1    0    0\n",
      "    1    1    0\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4QgCDgcbRA+T7AAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwMi1BdWctMjAxNyAyMjowNzoyN/ldGF0AACAA\nSURBVHic7d1/dBTlvfjxTyBCEAkBQSuwOqAFMbVir1STi2TxRwUVhWqjVorhW+XcetATG9oea28J\n13u5flUsYMGW0hI9+j3HiKBHqigqG/xeIlorWlALVgYXrRKVJTHyK2HvHxOXsNlsNpudeZ5n5v06\n+WMzOyxPHg7Pe3d2MpsXj8cFAADVeqkeAAAAIgQJAKAJggQA0AJBAgBogSABALRAkAAAWiBIAAAt\nECQAgBYIEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA\n0AJBAgBogSABCjz55JPf//73Lcs68cQTJ0yYsGzZspaWFtWDAhTLi8fjqscABEg8Hr/11lt/97vf\nJW0fP378xo0bCwoKlIwK0AGvkABPPfHEE06N+vTpM3Xq1NLSUmf766+/PnfuXKVDAxTjFRLgqbFj\nx7733nvy9VE7EXnsscdmzJghIkOHDt2zZ4/i8QHqECTAO83NzSeccIKIjB49+u9//7uz8dChQyef\nfHIsFhORjz/++JRTTlE5RECdfNUDAAJk9+7dAwYMEJHzzjsvsfHIkSMHDhwQkYKCgqFDhyobHKAa\nQQJcZttiWc7NMWPGNDY2Jt2/YMECJ0ilpaX5+fyXRHBxUgPgGtuWSZNk5EjJy5NJk8S2k+4/dOjQ\nT3/607vvvltE+vbt++C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kRW\nrFjx4x//2NvxAXrhpAbANZYlK1fKzp0Sj6esEYD2CBLgMstSPQLADByyAwBogVdIAAAtECQAgBYI\nEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA0AJBAgBo\ngSABALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQA\ngBYIEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA0AJB\nAgBogSABALRAkAAAWvhfMmf7upyH0HQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [1,0; 0,1; -1,0; 0,-1; 0,0; 1,0];        % nodes\n",
    "elem = [5,1,2; 5,2,3; 5,3,4; 5,4,6];            % elements\n",
    "elem = label(node,elem);                        % label the mesh\n",
    "figure;\n",
    "showmesh(node,elem);                            % plot mesh\n",
    "findelem(node,elem);                            % plot element indices\n",
    "findnode(node,2:6);                             % plot node indices\n",
    "text(node(6,1),node(6,2)+0.075,int2str(1),'FontSize',16,'FontWeight','bold');\n",
    "hold on;\n",
    "plot([node(1,1),node(5,1)], [node(1,2),node(5,2)],'r-', 'LineWidth',3);\n",
    "bdFlag = setboundary(node,elem,'Dirichlet');                % Dirichlet boundary condition\n",
    "display(elem)\n",
    "display(bdFlag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "bdFlag =\n",
      "\n",
      "    1    0    2\n",
      "    1    0    0\n",
      "    1    0    0\n",
      "    1    2    0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "bdFlag = setboundary(node,elem,'Dirichlet','abs(x) + abs(y) == 1','Neumann','y==0');\n",
    "display(bdFlag)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The red line represents a crack. Although node 1 and node 6 have the same coordinate (1,0), they are different nodes and used in different triangles. An array `u` with `u(1)~=u(6)` represents a discontinous function. Think about a paper cut through the red line. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: Prism Domain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "elem =\n",
      "\n",
      "     1     7     2     3\n",
      "     1     7     6     2\n",
      "     1     7     5     6\n",
      "\n",
      "\n",
      "bdFlag =\n",
      "\n",
      "    0    1    0    0\n",
      "    0    0    0    0\n",
      "    1    0    0    0\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4QgCDgwgFvCjAwAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwMi1BdWctMjAxNyAyMjoxMjozMpqSBBEAAB5w\nSURBVHic7d19cFT1vcfx7yabzTNFAgomUECiN0EQKgWCdkprePAqo7dpnaHiWHutdwYUpbe1LR0F\nR2XuyFRETaf24dZ6Rdoyar3gCAzSjoJBnhREEIg8FAJIAiRESLJhs/ePw91sNslmH845v9855/36\np2GTbH7Tgbz97J5sfOFwWAAAUC1D9QEAABAhSAAATRAkAIAWCBIAQAsECQCgBYIEANACQQIAaIEg\nAQC0QJAAAFogSAAALRAkAIAWCBIAQAsECQCgBYIEANACQQIAaIEgAQC0QJAAAFogSAAALRAkAIAW\nCBIAQAt+1QcANHLkyJGHHnqot/deffXVL730kp3nATyFIAGdzp8/v2bNmt7eO2rUKDsPA3gND9kB\nicrI4N8LYCH+gQGdRo8efaYb40E8n8/31FNPqT4g4Ga+cDis+gyAv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9fjnykHQcCzOPj\nby3gLPGDtGnTpptusu9HkQATZag+AIDUhf/fN7/5TdVnAdJFkACHiTyqwcMbcBmeQwKchxTBlVhI\nAAAtECQAgBa4yg4AoAUWEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYIEgBA\nCwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA0AJBAgBogSAB\nALRAkAAAWiBIAAAtECQAgBYIEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBYI\nEgBACwQJAKAFggQA0AJBAgBogSABALRAkAAAWiBIAAAtECQAgBb+DzdXo9z+TV3wAAAAAElFTkSu\nQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [-1,-1,-1; 1,-1,-1; 1,1,-1; -1,1,-1; -1,-1,1; 1,-1,1; 1,1,1; -1,1,1]; \n",
    "elem = [1,2,3,7; 1,6,2,7; 1,5,6,7];\n",
    "elem = label3(node,elem);\n",
    "figure;\n",
    "showmesh3(node,elem);\n",
    "view([-53,8]);\n",
    "findnode3(node,[1 2 3 5 6 7]);\n",
    "findelem3(node,elem);\n",
    "bdFlag = setboundary3(node,elem,'Dirichlet','(z==1) | (z==-1)');\n",
    "display(elem)\n",
    "display(bdFlag)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The top and bottom of the prism is set as Dirichlet boundary condition and other faces are zero flux boundary condition. Note that if the i-th face of t is on the boundary but `bdFlag(t,i)=0`, it is equivalent to use homogenous Neumann boundary condition (zero\n",
    "flux)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Remark\n",
    "\n",
    "It would save storage if we record boundary edges or faces only. The current data structure is convenient for the local refinement and coarsening since the boundary can be easily updated along with the change of elements. The matrix `bdFlag` is sparse but a dense matrix is used. We do not save `bdFlag` as a sparse matrix since updating sparse matrices is time consuming. Instead we set up the type of `bdFlag` to `uint8` to minimize the waste of memory."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Matlab",
   "language": "matlab",
   "name": "matlab"
  },
  "language_info": {
   "codemirror_mode": "octave",
   "file_extension": ".m",
   "help_links": [
    {
     "text": "MetaKernel Magics",
     "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
    }
   ],
   "mimetype": "text/x-matlab",
   "name": "matlab",
   "version": "0.14.3"
  },
  "toc": {
   "colors": {
    "hover_highlight": "#DAA520",
    "navigate_num": "#000000",
    "navigate_text": "#333333",
    "running_highlight": "#FF0000",
    "selected_highlight": "#FFD700",
    "sidebar_border": "#EEEEEE",
    "wrapper_background": "#FFFFFF"
   },
   "moveMenuLeft": true,
   "nav_menu": {
    "height": "102px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": true,
   "widenNotebook": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
